﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain;

namespace Data.ViewModels
{
    public class PerguntaViewModel
    {
        public string Title { get; set; }
        public int Votes { get; set; }
        public int Views { get; set; }
        public int Answers { get; set; }
        public User LastUpdateUser { get; set; }
        public int Id { get; set; }
        public string Body { get; set; }
        public IEnumerable<Tag> Tags { get; set; }
        private DateTime _LastUpdateDate;
        public DateTime LastUpdateDate
        {
            get {
                return _LastUpdateDate;
            } 
            set {
                _LastUpdateDate = value;
                TimeSpan elapsed = DateTime.Now.Subtract(_LastUpdateDate);

                if (elapsed.Days > 10)
                    LastUpdateDateFormated = LastUpdateDate.ToShortDateString();
                else if (elapsed.Days > 0)
                    LastUpdateDateFormated = elapsed.Days + " dias atrás";
                else if (elapsed.Hours > 0)
                    LastUpdateDateFormated = elapsed.Hours + "h atrás";
                else if (elapsed.Minutes > 0)
                    LastUpdateDateFormated = elapsed.Minutes + "m atrás";
                else if (elapsed.Seconds > 0)
                    LastUpdateDateFormated = elapsed.Seconds + "s atrás";
        } }
        public string LastUpdateDateFormated { get; set; }
    }
}
